package de.tmahr.android.logger;

import android.util.Log;
import android.widget.TextView;

public class BufferedTextViewLogger implements Logger
{
	private String tag;
	private TextView textView;
	private StringBuilder stringBuilder = new StringBuilder();
	
	public BufferedTextViewLogger(String tag, TextView textView)
	{
		this.tag = tag;
		this.textView = textView;
	}

	public void log(String s)
	{
		stringBuilder.append(s).append(" ");
		Log.d(tag,s);
		textView.setText(stringBuilder.toString());
	}
	
	public void clearLog()
	{
		stringBuilder.setLength(0);
	}
	
	public String getLoggedText()
	{
		return stringBuilder.toString();
	}
}
